package com.guigu.youxuan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.youxuan.common.vo.OrderDetailsByMidVo;
import com.guigu.youxuan.mapper.OrderDetailsMapper;
import com.guigu.youxuan.pojo.OrderDetails;
import com.guigu.youxuan.pojo.OrderInfo;
import com.guigu.youxuan.pojo.dto.OrderByMidDto;
import com.guigu.youxuan.service.IOrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liweixin
 * @since 2024-05-15
 */
@Service
public class OrderDetailsServiceImpl extends ServiceImpl<OrderDetailsMapper, OrderDetails> implements IOrderDetailsService {

    @Autowired
    private OrderDetailsMapper orderDetailsMapper;

    @Override
    public List<OrderDetails> OrderDate(int id) {
        List<OrderDetails> list = orderDetailsMapper.OrderDate(id);
        return list;
    }

    @Override
    public List<OrderDetails> queryOrderDetailsByMid(OrderDetailsByMidVo vo) {

        List<Date> dateList = vo.getOrderCreateTime();

        List<Integer> merchantIdList = vo.getMerchantId();

        List<OrderDetails> list = new ArrayList<>();
        if (dateList == null) {
            list = orderDetailsMapper.queryOrderDetailsByMid2(merchantIdList);
        }else {
            list = orderDetailsMapper.queryOrderDetailsByMid(merchantIdList,dateList.get(0).toLocaleString(),dateList.get(1).toLocaleString());
        }
        return list;
    }
}
